home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / scripts / control / is_controllable.m < prev    next >
Text File  |  1996-07-11  |  2KB  |  77 lines

  1. ## Copyright (C) 1996 John W. Eaton
  2. ##
  3. ## This file is part of Octave.
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation; either version 2, or (at your option)
  8. ## any later version.
  9. ##
  10. ## Octave is distributed in the hope that it will be useful, but
  11. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ## General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  18. ## 02111-1307, USA.
  19.  
  20. ## Usage: is_controllable (a, b {,tol})
  21. ##
  22. ## Returns 1 if the pair (a, b) is controllable, or 0 if not.
  23. ##
  24. ## See also: size, rows, columns, length, is_matrix, is_scalar, is_vector
  25. ##
  26. ## This should really use the method below, but I'm being lazy for now:
  27. ##
  28. ## Controllability is determined by applying Arnoldi iteration with
  29. ## complete re-orthogonalization to obtain an orthogonal basis of the
  30. ## Krylov subspace.
  31. ##
  32. ## (FIX ME... The Krylov subspace approach is not done yet!)
  33. ##                      n-1
  34. ##   span ([b,a*b,...,a^   b]).
  35. ##
  36. ## tol is a roundoff paramter, set to 2*eps if omitted.
  37.  
  38. ## Author: A. S. Hodel <scotte@eng.auburn.edu>
  39. ## Created: August 1993
  40. ## Adapted-By: jwe
  41.  
  42. function retval = is_controllable (a, b, tol)
  43.  
  44.   if (nargin == 2 || nargin == 3)
  45.  
  46.     n = is_square (a);
  47.     [nr, nc] = size (b);
  48.  
  49.     if (n == 0 || n != nr || nc == 0)
  50.       retval = 0;
  51.     else
  52.  
  53.       m = b;
  54.       tmp = b;
  55.       for ii = 1:(n-1)
  56.         tmp = a * tmp;
  57.         m = [m, tmp];
  58.       endfor
  59.  
  60.       ## If n is of any significant size, m will be low rank, so be careful!
  61.  
  62.       if (nargin == 3)
  63.         if (is_scalar (tol))
  64.           retval = (rank (m, tol) == n);
  65.         else
  66.           error ("is_controllable: tol must be a scalar");
  67.         endif
  68.       else
  69.         retval = (rank (m) == n);
  70.       endif
  71.     endif
  72.   else
  73.     usage ("is_controllable (a, b)");
  74.   endif
  75.  
  76. endfunction
  77.